package com.ma.chapter4.t4;

import com.ma.util.Sleeper;
import lombok.extern.slf4j.Slf4j;

/**
 * @ClassName TestWait
 * @Author: mayongqiang
 * @DATE 2022/3/8 19:43
 * @Description:
 */

@Slf4j(topic = "m.test")
public class TestWait {
    static final Object lock = new Object();

    public static void main(String[] args) {
        new Thread(() -> {
            synchronized (lock) {
                log.debug("获得锁");
                try {
                    //Thread.sleep(2000);
                    lock.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }, "t1").start();

        Sleeper.sleep(1);
        synchronized (lock) {
            log.debug("获得锁");
        }


    }
}
